Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom trusted header bitmasks #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matt-allan
Copy link

This PR adds support for custom bitmasks, which are necessary if your load balancer doesn't support all X-Forwarded-* headers and doesn't support the same subset of X-Forwarded-* headers that AWS ELB uses. I personally ran into this while using ngrok via valet share, which doesn't send HEADER_X_FORWARDED_PORT.

@fideloper
Copy link
Owner

Hi! I just wanted to let you know that this looks good on the surface. I'll likely pull it in when I have some extra time to test it out a bit more myself as well.

Thanks!

@fideloper
Copy link
Owner

Whoops, one more thing: Can you give an example of its usage? It looks like the test is an example, but I wanted to confirm that.

I'll use that to update the readme.md docs.

@matt-allan
Copy link
Author

Great, thanks for the update.

RE: usage you would typically start with Request::HEADER_X_FORWARDED_ALL and use a bitwise xor to exclude the headers you do not want, i.e.

// all x-forwarded-* headers except for x-forwarded-port
Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_PORT
// all x-forwarded-* headers except for x-forwarded-host
Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST

Here's an example from Symfony.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants